<?php
class Item_model extends MY_Model {
	public function __construct() {
		parent::__construct();
	}

	public function get_item_by_id($id)
    {
        $this->db->where("id",$id);
        $query=$this->db->get("ym_item");
        return $query->row_array();
    }
   
    public function get_item_list($filter)
    {
        $where = " AND pinpai = {$filter['pinpai']}";
        if(($filter['cat_id'] != '')){
            $where .= " AND categoryid = {$filter['cat_id']}";
        }
		$sql = "SELECT * FROM ym_item WHERE isDel=0  {$where} ORDER BY  addtime DESC";
		$query = $this->db->query($sql);
        return $query->result_array();        
    }
    public function getCatList()
    {
        $sql = "SELECT * FROM ym_item_category";
        $query = $this->db->query($sql);

        return $query->result_array();
    }

      //获取图片列表
    public function get_img_list_byid($id){
        $this->db->where("itemid",$id);
        $query = $this->db->get("ym_item_attach");
        $imageInfo = $query->row_array();
        return $imageInfo['imgurl'];
    }


}



